﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Work.UI.Web.Forms.Admin.Users.Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentHeader" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <asp:ObjectDataSource ID="odsUser" runat="server"
        TypeName="Work.BL.Hibernate.Managers.HUserManager"
        DataObjectTypeName="Work.BL.POCOs.UserPOCO"
        SelectMethod="GetUserById"
        UpdateMethod="Edit"
        onobjectcreating="odsRegion_ObjectCreating">

            <SelectParameters>
                <asp:QueryStringParameter Name="userId" QueryStringField="Id" Type="Int32" />
            </SelectParameters>

        </asp:ObjectDataSource>

    <asp:FormView ID="frvUser"  runat="server"
        
        DataSourceID="odsUser"
        DataKeyNames="Id" DefaultMode="Edit" 
        OnItemUpdated="frvRegion_ItemUpdate" >

        <EditItemTemplate>

            <table class="addEdit">

                <tr>
                    <td>Name: </td>
                    <td>
                        <asp:TextBox ID="tbName" Text='<%# Bind("Name") %>' runat="server"/>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                ErrorMessage="Required field"
                                ValidationGroup="user"
                                ControlToValidate="tbName" 
                                Display="Dynamic"/>
                        <asp:RegularExpressionValidator ID="revSmallName" runat="server" 
                                ErrorMessage="Length should not exceed 25"                                                                                                             
                                ControlToValidate="tbName"
                                ValidationGroup="user" 
                                ValidationExpression=".{1,25}"
                                Display="Dynamic" />
                    </td>
                </tr>

                <tr>
                    <td>Email: </td>
                    <td>
                        <asp:TextBox ID="tbEmail" Text='<%# Bind("Email") %>' runat="server"/>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                ErrorMessage="Required field"
                                ValidationGroup="user"
                                ControlToValidate="tbEmail" 
                                Display="Dynamic"/>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                ErrorMessage="Length should not exceed 25"                                                                                                             
                                ControlToValidate="tbEmail"
                                ValidationGroup="user" 
                                ValidationExpression=".{1,25}"
                                Display="Dynamic" />
                    </td>
                </tr>

                <tr>
                    <td>Password </td>
                    <td>
                        <asp:TextBox ID="tbPass" Enabled="false" Text='<%# Bind("Password") %>' runat="server"/>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                ErrorMessage="Required field"
                                ValidationGroup="user"
                                ControlToValidate="tbPass" 
                                Display="Dynamic"/>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                ErrorMessage="Length should not exceed 25"                                                                                                             
                                ControlToValidate="tbPass"
                                ValidationGroup="user" 
                                ValidationExpression=".{1,25}"
                                Display="Dynamic" />
                    </td>
                </tr>

            </table>
            <asp:TextBox ID="TextBox1" Visible="false" Text='<%# Bind("Roles") %>' runat="server"/>

            <asp:LinkButton ID="AddUser" runat="server" ValidationGroup="user"
                onclick="AddRegion_Click" CausesValidation="true" CssClass="button1">
                    <strong>Edit</strong>
                </asp:LinkButton>

            <asp:LinkButton ID="LinkButton1" runat="server" ValidationGroup="region"
                onclick="Cansel_Click" CausesValidation="true" CssClass="button1">
                    <strong>Cansel</strong>
                </asp:LinkButton>
                
            </EditItemTemplate>

        </asp:FormView>

</asp:Content>
